import os
import pytest
from dotenv import load_dotenv


@pytest.fixture(scope="session", autouse=True)
def getevn():
    print("整个项目运行前", os.getenv("db_host"))
    yield
    print("整个项目运行后", os.getenv("db_host"))


def pytest_addoption(parser):
    parser.addoption(
        "--env-file",
        action="store",
        default='.env'
    )


def pytest_configure(config):
    env_file = config.getoption("--env-file") or ".env"
    load_dotenv(env_file)



